package com.youlu.campus.admin.live.controller;

import com.youlu.campus.admin.live.dto.*;
import com.youlu.campus.admin.live.service.LiveService;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 直播管理控制层
 * 描述：直播管理
 * @author: YangJ
 * @date: 2020/11/11 15:03
 */
@RestController
public class LiveController {

    @Autowired
    private LiveService liveService;

    /**
     * 创建直播间
     * @param request 直播间创建请求类
     * @return
     */
    @PostMapping("/live/room/create")
    public QResult createLiveRoom(@RequestBody LiveRoomCreateRequest request){
        boolean result = liveService.createLiveRoom(request);
        return QResult.success(result);
    }

    /**
     * 直播间列表
     * @param request 直播间查询请求类
     * @return 请求成功时返回LiveRoomResponse对象
     */
    @PostMapping("/live/room/list")
    public QResult liveRoomList(@RequestBody LiveRoomQueryRequest request){
        return QResult.success(liveService.liveRoomList(request));
    }

    /**
     * 删除直播间
     * @param id 直播间ID
     * @return
     */
    @DeleteMapping("/live/room/delete")
    public QResult deleteLiveRoom(String id){
        boolean result = liveService.deleteLiveRoom(id);
        return QResult.success(result);
    }

    /**
     * 创建直播排期
     * @param request 直播信息创建请求类
     * @return
     */
    @PostMapping("/live/create")
    public QResult createLive(@RequestBody LiveCreateRequest request){
        boolean result = liveService.createLive(request);
        return QResult.success(result);
    }

    /**
     * 修改直播排期
     * @param request 直播信息修改请求类
     * @return
     */
    @PostMapping("/live/update")
    public QResult updateLive(@RequestBody LiveUpdateRequest request){
        boolean result = liveService.updateLive(request);
        return QResult.success(result);
    }

    /**
     * 删除直播排期
     * @param id 直播排期ID
     * @return
     */
    @DeleteMapping("/live/delete")
    public QResult deleteLive(String id){
        boolean result = liveService.deleteLive(id);
        return QResult.success(result);
    }

    /**
     * 直播排期列表
     * @param request 直播信息查询请求类
     * @return 请求成功时返回LiveResponse对象
     */
    @PostMapping("/live/list")
    public QResult liveRoomList(@RequestBody LiveQueryRequest request){
        return QResult.success(liveService.liveList(request));
    }

    /**
     * 直播排期查询
     * @param id 直播排期ID
     * @return 请求成功时返回LiveResponse对象
     */
    @GetMapping("/live/query")
    public QResult liveRoomList(String id){
        return QResult.success(liveService.query(id));
    }
}